//index.js
//获取应用实例
var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		account:app.setting.account,
		pagetitle:'积分排行' + '-' + app.setting.title,
		
	},
	onReady: function (){
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (){
		var page=this;
		wx.setNavigationBarTitle({'title':page.data.pagetitle});
		app.util.get(app.access,function(pagedata){
			//console.log('pagedata');console.log(pagedata);
			page.setData({
				pagedata:pagedata
			});
			page.get_list(1);
		});
	},
	get_list:function(e){
		var the=this;
		var page = the.data.page
		var pagedata=the.data.pagedata
		if(e==1){
			page = 1;
			pagedata.list=[];
		}	
		var query='page='+page;	
		app.util.get('/member.rank/getlist/'+query,function(res){
			console.log(res);
			pagedata.list = pagedata.list.concat(res.list)
			page++
			the.setData({
				'pagedata.list':pagedata.list,
				page:page,
				loading:false,
			});
		});
	},
  	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		app.util[data.func](data.params);
	},
	formSubmit:function(event){
		var data=event.detail.value;
		app.util.post('post',data);
	}
});